package com.imooc.activitiweb.service.impl;


import com.imooc.activitiweb.mapper.UserInfoBeanMapper;
import com.imooc.activitiweb.pojo.UserInfoBean;
import com.imooc.activitiweb.security.MyUserDetailsService;
import com.imooc.activitiweb.service.userService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service

public class userServiceImpl implements userService {


    @Autowired
    UserInfoBeanMapper mapper;

    @Autowired
    MyUserDetailsService myUserDetailsService;

    @Override
    public void save(UserInfoBean userInfoBean) {
        //设置主键的值

        //String password = new Md5Hash("123456",user.getMobile(),3).toString();

        String password = myUserDetailsService.passwordEncoder().encode(userInfoBean.getPassword());
        //userInfoBean.setUsername("username");
        userInfoBean.setPassword(password);//设置初始密码
        //userInfoBean.setRoles("ROLE_ACTIVITI_USER,GROUP_activitiTeam");
        //userInfoBean.setName("name");

        //调用dao保存部门
        mapper.insertByUsername(userInfoBean);

    }
}
